package com.zhang.service.Impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.zhang.domain.Department;
import com.zhang.domain.orderAddress;
import com.zhang.mapper.AddressMapper;
import com.zhang.query.BaseQuery;
import com.zhang.service.IAddressService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author zh
 * @create 2022-03-14 14:19
 */
@Service
public class AddressServiceImpl implements IAddressService {
    @Resource
    private AddressMapper mapper;
    @Override
    public void add(orderAddress d) {
        mapper.save(d);
    }

    @Override
    public void update(orderAddress d) {
        mapper.update(d);
    }

    @Override
    public void delete(Long id) {
        mapper.delete(id);
    }

    @Override
    public PageInfo<orderAddress> selectData(BaseQuery query) {
        PageHelper.startPage(query.getCurrentPage(),query.getPageSize());
        List<orderAddress> orderAddress = mapper.queryData(query);
        Page<orderAddress> page = (Page<orderAddress>) orderAddress;
        return page.toPageInfo();
    }
}
